package org.jeecg.modules.simulator.factory.person;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.Getter;
import lombok.Setter;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.simulator.jsonot.ODRoutes;
import org.jeecg.modules.simulator.jsonot.RoutePath;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.List;

public class RouteObjecter {

    private final String prefixRouteName = "Simu_";

    @Getter
    @Setter
    private RedisTemplate<String, Object> redisTemplate;

    public  ODRoutes getODRoutesObject(String routeId){
        String querystr=prefixRouteName+routeId;
        System.out.println(querystr);

        if(redisTemplate.hasKey(querystr)){
            String jsonResult = oConvertUtils.getString(redisTemplate.opsForValue().get(querystr));
            Gson gson = new GsonBuilder().setPrettyPrinting().create();
            ODRoutes odRoutes = gson.fromJson(jsonResult, ODRoutes.class);
            return odRoutes;
        }

        return null;

//        List<RoutePath> routePathList = odRoutes.getRoutePathList();

//        return routePathList;
    }



}
